home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / exec / allocvec.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  96 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: allocvec.c,v 1.7 1996/10/24 15:50:45 aros Exp $
  4.     $Log: allocvec.c,v $
  5.     Revision 1.7  1996/10/24 15:50:45  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.6  1996/10/23 14:13:43  aros
  9.     Use AROS_ALIGN() to align pointers
  10.  
  11.     Revision 1.5  1996/10/19 17:07:24  aros
  12.     Include <aros/machine.h> instead of machine.h
  13.  
  14.     Revision 1.4  1996/08/13 13:55:58  digulla
  15.     Replaced AROS_LA by AROS_LHA
  16.     Replaced some AROS_LH*I by AROS_LH*
  17.     Sorted and added includes
  18.  
  19.     Revision 1.3  1996/08/01 17:41:05  digulla
  20.     Added standard header for all files
  21.  
  22.     Desc:
  23.     Lang:
  24. */
  25. #include "exec_intern.h"
  26. #include <aros/libcall.h>
  27. #include <aros/machine.h>
  28. #include "memory.h"
  29.  
  30. /*****************************************************************************
  31.  
  32.     NAME */
  33.     #include <clib/exec_protos.h>
  34.  
  35.     AROS_LH2(APTR, AllocVec,
  36.  
  37. /*  SYNOPSIS */
  38.     AROS_LHA(ULONG, byteSize,     D0),
  39.     AROS_LHA(ULONG, requirements, D1),
  40.  
  41. /*  LOCATION */
  42.     struct ExecBase *, SysBase, 114, Exec)
  43.  
  44. /*  FUNCTION
  45.     Allocate some memory from the sytem memory pool with the given
  46.     requirements and without the need to memorize the actual size
  47.     of the block.
  48.  
  49.     INPUTS
  50.     byteSize     - Number of bytes you want to get
  51.     requirements - Type of memory
  52.  
  53.     RESULT
  54.     A pointer to the number of bytes you wanted or NULL if the memory
  55.     couldn't be allocated
  56.  
  57.     NOTES
  58.  
  59.     EXAMPLE
  60.  
  61.     BUGS
  62.  
  63.     SEE ALSO
  64.     FreeVec()
  65.  
  66.     INTERNALS
  67.  
  68.     HISTORY
  69.     8-10-95    created by m. fleischer
  70.        16-10-95    increased portability
  71.  
  72. ******************************************************************************/
  73. {
  74.     AROS_LIBFUNC_INIT
  75.  
  76.     UBYTE *ret;
  77.  
  78.     /* Add room for stored size. */
  79.     byteSize+=AROS_ALIGN(sizeof(ULONG));
  80.  
  81.     /* Get the memory. */
  82.     ret=(UBYTE *)AllocMem(byteSize,requirements);
  83.  
  84.     /* If there's not enough memory left return immediately. */
  85.     if(ret==NULL)
  86.     return NULL;
  87.  
  88.     /* Store size */
  89.     *(ULONG *)ret=byteSize;
  90.  
  91.     /* return free space */
  92.     return ret+AROS_ALIGN(sizeof(ULONG));
  93.     AROS_LIBFUNC_EXIT
  94. } /* AllocVec */
  95.  
  96.